
<div id="main">
    <div id="contents">
        <form method="post" action="#" name="filters">
            <fieldset>
                <legend>
                    <label sid="wps.config"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%">
                        <tbody>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="id2210">
                                    <label sid="wps.wps"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="id2210_1" type="radio" checked="" value="7" name="id2210">
                                <label sid="main.enable"></label>
                                <span style="padding-left:20px;"></span>
                                <input id="id2210_2" type="radio" value="0" name="id2210">
                                <label sid="main.disable"></label>
                            
                            </td>
                        </tr>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="pin">
                                    <label sid="wps.route_pin"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="pin" type="text" readonly="true" maxlength="17" size="15" name="pin">
                                <input sid='wps.generate' class = 'button' type ='button' name = 'generate' onclick="getpin();"/>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_center" colspan="2">
                                <input sid='sbutton.save' class = 'button' type ='button' name = 'submit1'/>

                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </fieldset>
            <fieldset>
                <legend>
                    <label sid="wps.progress"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%">
                        <tbody>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="PINPBCRadio"></label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="PINPBCRadio_1" type="radio" checked="" onclick="read();" value="1" name="id2354">
                                <label sid="wps.pin_mode"></label>
                               <span style="padding-left:20px;"></span>
                                <input id="PINPBCRadio_2" type="radio" onclick="read();" value="2" name="id2354">
                                <label sid="wps.pbc_mode"></label>
                            </td>
                        </tr>
                        <tr id="trPIN">
                            <td class="frame_tab_left">
                                <label for="id2355">
                                    <label sid="wps.pin_num"></label>
                                </label>
                            </td>
                            <td class="frame_tab_right">
                                <input id="id2355" maxlength="31" size="17" name="id2355">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_center" colspan="2">
                                <input sid='wps.conn' class = 'button' type ='button' name = 'submit2'/>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </fieldset>
            <fieldset id="wpsstat" style="display:none;">
                <legend>
                    <label sid="wps.summary"></label>
                </legend>
                <div class="frame_tab_layer">
                    <table class="cmenutitle" cellspacing="0" cellpadding="0" border="0" width="100%">
                        <tbody>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="WPSCurrentStatus">
                                    <label sid="wps.current_status"></label>
                                </label>
                            </td>
                            <td id="WPSCurrentStatus" class="frame_tab_right"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="WPSConfigured">
                                    <label sid="wps.configured"></label>
                                </label>
                            </td>
                            <td id="WPSConfigured" class="frame_tab_right"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="WPSSSID">
                                    <label sid="wps.ssid"></label>
                                </label>
                            </td>
                            <td id="WPSSSID" class="frame_tab_right"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="WPSAuthMode">
                                    <label sid="wps.auth_mode"></label>
                                </label>
                            </td>
                            <td id="WPSAuthMode" class="frame_tab_right"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="WPSEncryptype">
                                    <label sid="wps.encryp_type"></label>
                                </label>
                            </td>
                            <td id="WPSEncryptype" class="frame_tab_right"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="WPSDefaultKeyIndex">
                                    <label sid="wps.default_key_index"></label>
                                </label>
                            </td>
                            <td id="WPSDefaultKeyIndex" class="frame_tab_right"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="WPSWPAKey">
                                    <label sid="wps.wpa_key"></label>
                                </label>
                            </td>
                            <td id="WPSWPAKey" class="frame_tab_right"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_left">
                                <label for="WPSPIN">
                                    <label sid="wps.ap_pin"></label>
                                </label>
                            </td>
                            <td id="WPSPIN" class="frame_tab_right"></td>
                        </tr>
                        <tr>
                            <td colspan="2"></td>
                        </tr>
                        <tr>
                            <td class="frame_tab_center" colspan="2">
                                <input class="button" type="button" name="submit3" sid="wps.reset_oob" onclick="resetoob();"/>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </fieldset>
        </form>
    </div>
</div>
<br>
<div id="helpContainer">
    <div id="help">
        <div>
            <h2>
                <label sid="share.help"></label>
            </h2>
        </div>
        <div id="helpBody">
        <dl>
            <dt class="term">
                <label sid="wps.summary"></label>
            </dt>
            <dd class="definition">
                <label sid="wps.summary_note"></label>
            </dd>

            <dt class="term">
                <label sid="wps.pin_mode"></label>
            </dt>
            <dd class="definition">
                <label sid="wps.pin_mode_note"></label>
            </dd>
            <dt class="term">
                <label sid="wps.pbc_mode"></label>
            </dt>
            <dd class="definition">
                <label sid="wps.pbc_mode_note"></label>
            </dd>
            <dt class="term">
                <label sid="wps.reset_oob"></label>
            </dt>
            <dd class="definition">
                <label sid="wps.reset_oob_note"></label>
            </dd>
            <dt class="term">
                <label sid="wps.current_status"></label>
            </dt>
            <dd class="definition">
                <label sid="wps.current_status_note"></label>
            </dd>
        </dl>
        </div>
    </div>
</div>



<script type="text/javascript">
	var wps_status;
	var wps_result;
	load_html();
	function load_html(){
	var sendtext = "&id=2210";
	DataRequest("get_json",sendtext,function(data){
		var value2210=data["id2210"];
		if(value2210=="0"){value2210="0";}else{value2210="7";}
  		updatecfgvalue("id2210",value2210);
  		 DataRequest("/cgi-bin/stat?wpssummery","",function(data){
		var tmpvalue = data["wpssummery"];
		if(tmpvalue=="wifioff"){
			$("#wpsstat").hide();
		}else if(tmpvalue&&tmpvalue!=""){
		$("#wpsstat").show();
		var all_str = tmpvalue.split(",");
	if(all_str[0] == "1" || all_str[0] == "0"){
	$("#WPSConfigured").html("No");
	}else if(all_str[0] == "2"){
		$("#WPSConfigured").html("Yes");
	}else{
		$("#WPSConfigured").html("Unknown");
	}
	$("#WPSSSID").html( all_str[1]);
	var pwsmode = all_str[2];
	if(pwsmode=="WPA-PSKWPA2-PSK"){
			pwsmode="WPA/WPA2-PSK";
		}
	$("#WPSAuthMode").html( pwsmode);
	$("#WPSEncryptype").html( all_str[3]);
	$("#WPSDefaultKeyIndex").html( all_str[4]);
	if(all_str[3] == "WEP"){
		$("#WPSKeyType").html( "WPS Key(Hex value)");
	}else{
		$("#WPSKeyType").html( "WPS Key(ASCII)");
	}
	if(all_str[5]=="0"){var wpakey = "--";}else{var wpakey=all_str[5];}
	$("#WPSWPAKey").html(wpakey);
	$("#WPSCurrentStatus").html( all_str[6]);

	if(all_str[7] == "-1"){
	    $("#WPSInfo").html("WSC failed");
	}else if(all_str[7] == "0"){
		 $("#WPSInfo").html("WSC:" + all_str[6]);
	}else if(all_str[7] == "1"){
		$("#WPSInfo").html("WSC Success");
	}
	wps_result = all_str[7];
	wps_status = all_str[8];
	DataRequest("/cgi-bin/stat?wpsgetpin","",function(data){
		var tmpvalue1 = data["wpspin"];
		$("#WPSPIN").html(tmpvalue1);
		$("#pin").attr("value",tmpvalue1);
	});
	}
	});
  });
 }
 
function resetoob(){
	submitform(modules["set_data"],"&id2357=1");
	load_html();
}

function getpin(){
	submitform(modules["set_data"],"&id2356=1");
	DataRequest("/cgi-bin/stat?wpsgetpin","",function(data){
		var tmpvalue = data["wpspin"];
		$("#pin").attr("value",tmpvalue);
		$("#WPSPIN").html(tmpvalue);
	});
}

	$("[name=submit1]").click(function () {
		if($("#id2210_1").attr("checked")){
			var settext = '&id2210=7';
		}else{
			var settext = '&id2210=0';
		}
		//settext+= "&id2356="+$("#pin").val();
		submitform(modules["set_data"],settext);
	});
	
	$("[name=submit2]").click(function () {
		$(".errormsg").html('');
		var settext = '';
		if($("#PINPBCRadio_1").attr("checked")){
			settext += '&id2354=1';
		}else{
			settext += '&id2354=2';
		}
		settext+="&id2355="+$("#id2355").val();
		settext=settext.replace(/\#/g,"%23");
		submitform(modules["set_data"],settext);
	});
	
	function read(){
		if($("#PINPBCRadio_1").attr("checked")){
				$("#trPIN").show();
			}else{
				$("#trPIN").hide();
			}
		}
</script>

